package Function;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class Delete implements All {
    @Override
    public void work(BookList book) {

        System.out.println("请输入你要删除书籍名字：");
        Scanner in=new Scanner(System.in);
        String bookname5=in.nextLine();
        for(int i=0;i< book.getCount();i++){
            if(bookname5.equals(book.getBook1(i).getName())){
                for(int j=i;j< book.getCount()-1;j++){
                    Book booktemp=book.getBook1(j+1);//创建一个与数组对象类型相同的变量接收便于赋值
                    book.setBook1(booktemp,j);//利用set方法把就j+1所指对象覆盖j+1下标所指的对象
                }
                book.setCount(book.getCount()-1);//删除后书数量减1
                System.out.println("删除成功------");
                return ;
            }
        }
        System.out.println("未找到您要的图书，删除失败！！！！！");
        return;
    }
}
